package com.example.homework6;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

public class Fragment2 extends Fragment {
    public Fragment2(){
        super(R.layout.fragment2);
    }

    public void onViewCreated(@NonNull View view, @NonNull Bundle saveInstanceState){
        super.onViewCreated(view,saveInstanceState);

        //打开百度
        Button button1 = getView().findViewById(R.id.bt_baidu);
        button1.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                intent.setData(Uri.parse("https://www.baidu.com/"));
                startActivity(intent);
            }
        });


        //打开哔哩哔哩
        Button button2 = getView().findViewById(R.id.bt_BILIBILI);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=getActivity().getPackageManager().getLaunchIntentForPackage("tv.danmaku.bili");
                startActivity(intent);
            }
        });


        //打开网易云
        Button button3 = getView().findViewById(R.id.bt_wyy);
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=getActivity().getPackageManager().getLaunchIntentForPackage("com.netease.cloudmusic");
                startActivity(intent);
            }
        });
    }
}
